class StringUtils {
  static String mask(String text) {
    if (text == null) {
      return '';
    }

    switch (text.length) {
      case 0:
        return '';
      case 1:
        return '*';
      case 2:
        return '${text.substring(0, 1)}*';
      default:
        final leading = text.substring(0, 1);
        final trailing = text.substring(text.length - 1, text.length);

        return '$leading***$trailing';
    }
  }
}
